<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.listForm.DingDanQueRen"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>

<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

    <section class="content-header">
        <h1>未完成订单</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">药品配送</a></li>
            <li class="active"><a href="#">未完成订单</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input" style="margin-top:-5px;">
                    <div class="textalign1"><spring:message code="message.lable.yiLiaoJiGouMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="hospName" name="hospName" placeholder="<spring:message code="message.lable.yiLiaoJiGouMingCheng"/>/<spring:message code="message.listForm.pinYinMa"/>" />
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.YiLiaoJiGouDiQu"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                       <table style="width:100%;">
                           <tr>
                              <td style="width:33%">
                                <select class="textinput" id="area1" name="area1" disabled="disabled">
                                    <option value="${area.areaId}">${area.areaName}</option>
                                </select>
                              </td>
                              <td style="width:33%">   
                                <select class="textinput" id="area2" name="area2" ></select>
                                </td>
                              <td style="width:33%">
                                <select class="textinput" id="area3" name="area3" ></select>
                              </td>
                           </tr> 
                        </table>     
                    </div>
                    <div class="textalign"><spring:message code="message.listForm.DingDanBaoHao"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                        <input type="text" class="textinput" id="orderPackId" name="orderPackId" placeholder="<spring:message code="message.listForm.DingDanBaoHao"/>" />
                    </div>
                </div>
                <div class="input" style="margin-top:-5px">
                    <div class="textalign1"><spring:message code="message.listForm.CaiGouRiQi"/><spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput"> 
                       <table style="width:100%">
                                <tr>
                                    <td style="width:50%">
                                        <input id="startDate" name="startDate" type="text" class="textinput" placeholder="yyyy-MM-dd" 
                                            data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')}'})" />
                                    </td>
                                    <td>&nbsp;-&nbsp;</td>
                                    <td style="width:50%">
                                        <input id="endDate" name="endDate" type="text" class="textinput"  placeholder="yyyy-MM-dd" 
                                        data-date-fmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDate\')}'})" /> 
                                    </td> 
                                </tr>
                            </table>
                    </div>
                       <div class="textalign">订单状态：</div>
                	<div class="boxinput">
                		<select  class="textinput" id="orderStatus" name="orderStatus" placeholder="状态" >
                			<option value=''>请选择</option>
                			<option value='1'>已提交</option>
                			<option value='11'>已发送</option>
                			<option value='2'>已确认</option>
                			<option value='3'>部分配送</option>
                			<option value='4'>配送完成</option>
                			<option value='13'>缺货</option>
                			
                			
                		</select>
                	</div> 
                    <div class="textalign" >
                    <button type="button" class="btn btn-success btn-sm" onclick="search()" id="selectDicCompType"><spring:message code="message.button.seachSpacing"/></button>
                    </div>  
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        function showOrderDetail(orderPackId) {
            $.HN.window.open({
                "id" : "orderDetail",
                "title" : "订单明细",
                "url" : "${ctx}/purOrderInfo/toOrderDetailByComp.html?orderPackId=" + orderPackId
            });
        }
        
        function orderDetailLink(orderPackId, text) {
            return "<a href='javascript:showOrderDetail(\"" + orderPackId + "\")'  style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='明细'></a>";
        }
    
        $(function () {
            //绑定回车
            $('#hospName,#area1,#area2,#area3,#orderPackId,#startDate,#endDate').bind('keydown', function(event) {
                if (event.keyCode == "13") {
                    $('#selectDicCompType').click();
                }
            }); 
            
            $("#hospName").focus();//加载页面光标在第一个查询框内
            
            $("#gridlist").jqGrid({
                url: "getOrderListByComp.html",
                mtype: "POST",
                datatype: "json",
                shrinkToFit: false,
                autowidth: true,
             //   height: 300,
                colNames: [
                    '操作',
                    '订单状态',
                    '<spring:message code="message.listForm.DingDanBaoHao"/>', 
                    '<spring:message code="message.lable.yiLiaoJiGouMingCheng"/>', 
                    '<spring:message code="message.listForm.YiLiaoJiGouDiQu"/>',
                    '<spring:message code="message.listForm.CaiGouShiJian"/>',
                    '<spring:message code="message.listForm.TiaoMuShu"/>', 
                    '<spring:message code="message.listForm.ZongJinE"/>',
                    '<spring:message code="message.listForm.JiaJiDingDan"/>',
                    '收货人',
                    '收货人电话',
                    '送货地址',
                    '<spring:message code="message.lable.hospRemark"/>'
                ],
                colModel: [
                    { name: 'operate', width: 60 , align:"center" ,sortable: false,
                        formatter:function(cellvalue, options, row){
                            return orderDetailLink(row.orderPackId, '明细');
                        }
                    },
                    { name: 'orderStatus', width: 80 , align:"center" ,sortable: false },
                    { name: 'orderPackId', width: 180 , align:"center" ,sortable: false },
                    { name: 'hospName', width: 180 , align:"left" ,sortable: false},
                    { name: 'hospArFullname', width: 120 , align:"center" ,sortable: false},
                    { name: 'submitDatetime', width: 160 , align:"center" ,sortable: false},
                    { name: 'count', width: 60 , align:"center",sortable: false},
                    { name: 'amount', width: 80 , align:"right",sortable: false,
                        formatter : function(val, opts, row) {
                            return formatAmount(val);
                        }
                    },
                    { name: 'isUrgent', width: 80 , align:"center",sortable: false,
                        formatter : function(val, opts, row) {
                            if (val == 1) {
                                return "<span class='red'>是</span>";
                            }
                            return "否";
                        }
                    },
                    { name: 'recpUser', width: 100 , align:"center" ,sortable: false },
                    { name: 'recpUserphone', width: 120 , align:"center" ,sortable: false },
                    { name: 'recpAddr', width: 300 , align:"left" ,sortable: false },
                    { name: 'remarks', width: 250 , align:"left" ,sortable: false }
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                multiselect: false,
                pager: "#gridpage",
                viewrecords: true,
                gridComplete:function(){
                    //序号列宽度自适应（参数为jqgridID）
                    autoRNWidth("gridlist");
                    //数据只有一条时默认选中（参数为jqgridID）
                    selectByOneData("gridlist");
                },
                caption: "未完成订单列表",
                jsonReader: {
                    repeatitems: false,
                    id: "orderPackId"
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
			$("#gridlist").jqGrid("setGridHeight", create());
            
            
             /* 医疗机构所属地区 */
             $("#area2").HNSelect({
                 parent_selector: "#area1",  url: "${ctx}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                 func: function () {
                     $("#area3").HNSelect({
                         parent_selector: "#area2", url: "${ctx}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                     });
                 }
             });
        });
        
        
        /* 查询 */
        function search(page) {
            var orderPackId = $.trim($("#orderPackId").val());
            var hospName = $.trim($("#hospName").val());
            var areaId = $.trim($("#area3").val());
            if(areaId == null || areaId==""){
                areaId=$.trim($("#area2").val());
            }
            var startDate = $("#startDate").val();
            var endDate = $("#endDate").val();
            $("#gridlist").jqGrid("clearGridData");
                $("#gridlist").jqGrid('setGridParam',{  
                mtype: "POST",
                datatype:'json',
                postData:{
                    "orderPackId":orderPackId,
                    "hospName":hospName,
                    "areaId":areaId,
                    "startDate":startDate,
                    "endDate":endDate,
                    "orderStatus":$("#orderStatus").val()
                },
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
        
    </script>
</body>
</html>